//
//  GSDKWelcomeViewController.m
//  GameSDK
//
//  Created by Johnny on 2017/8/1.
//  Copyright © 2017年 Johnny. All rights reserved.
//

#import "GSDKWelcomeViewController.h"
#import "Masonry.h"
#import "GSDKLoadDotView.h"
#import "UIViewController+Extension.h"
#import "GSDKCommonMethod.h"
@interface GSDKWelcomeViewController ()

@end

@implementation GSDKWelcomeViewController
- (void)dealloc {
    DEBUGMSG(@"GSDKWelcomeViewController dealloc");
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initDotView];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark ---- DotView
- (void)initDotView {
    //启动页视图
    _loadWelComeDateView = [UIView new];
    [self.view addSubview:_loadWelComeDateView];
    _loadWelComeDateView.backgroundColor = [UIColor whiteColor];
    [_loadWelComeDateView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.equalTo(@0);
    }];
    
    //logo视图
    UIImageView * startBgImgView = [UIImageView new];
    startBgImgView.image = [UIImage imageNamed:@"ZYSDK_Resourcres.bundle/pic/ZYGAME"];
    startBgImgView.backgroundColor = [UIColor clearColor];
    [_loadWelComeDateView addSubview:startBgImgView];
    [startBgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.centerY.equalTo(self.view).offset(-32);
        make.width.equalTo(@273);
        make.height.equalTo(@80);
    }];
    
    //加载动画
    self.loadDotView = [GSDKLoadDotView new];
    [self.loadDotView initView];
    [self.loadWelComeDateView addSubview:self.loadDotView];
    [self.view addSubview:self.loadWelComeDateView];
    [self.loadDotView startAnimating];
    [self.loadDotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(startBgImgView.mas_bottom).offset(10.0);
        make.centerX.equalTo(startBgImgView.mas_centerX);
        make.width.equalTo(@148);
        make.height.equalTo(@70);
    }];
}

- (void)clean {
    
    [UIView animateWithDuration:0.25 animations:^{
        [self.view setFrame:CGRectMake(-[GSDKCommonMethod getWidth], 0, [GSDKCommonMethod getWidth], [GSDKCommonMethod getHight])];
    } completion:^(BOOL finished) {
        [self.loadDotView stopAnimating];
        [self.view removeFromSuperview];
    }];
    
}

+ (GSDKWelcomeViewController *)show {
    GSDKWelcomeViewController * vc = [GSDKWelcomeViewController new];
    [vc.view setFrame:CGRectMake(0, 0, [GSDKCommonMethod getWidth], [GSDKCommonMethod getHight])];
    [[UIViewController getCurrentRootViewController].view addSubview:vc.view];
    return vc;
}

@end
